home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tools / utils / twtcp122 / pktdrv / pktlance / pktdrv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-25  |  1.9 KB  |  94 lines

  1. #include "cookie.h"
  2. #include "pktdrv.h"
  3.  
  4. #define NULL (void *)0L
  5.  
  6.  
  7. int net_info(int len, char *buf)
  8. {
  9. static int (*n_info)(int,char *) = NULL;
  10. COOKIE *cookie;
  11.     if(!n_info)
  12.     {
  13.         cookie = get_cookie(PKTCOOKIE);
  14.         if(!cookie || !cookie->val) return(-1);
  15.         (long)n_info = ((long *)(cookie->val))[NETINFO];
  16.         if(!n_info) return(-1);
  17.     }
  18.     return(n_info(len,buf));
  19. }
  20.  
  21.  
  22. int net_open(int type, pkt_hndl handler)
  23. {
  24. static int (*n_open)(int,pkt_hndl) = NULL;
  25. COOKIE *cookie;
  26.     if(!n_open)
  27.     {
  28.         cookie = get_cookie(PKTCOOKIE);
  29.         if(!cookie || !cookie->val) return(-1);
  30.         (long)n_open = ((long *)(cookie->val))[NETOPEN];
  31.         if(!n_open) return(-1);
  32.     }
  33.     return(n_open(type,handler));
  34. }
  35.  
  36.  
  37. int net_release(int handle)
  38. {
  39. static int (*n_release)(int) = NULL;
  40. COOKIE *cookie;
  41.     if(!n_release)
  42.     {
  43.         cookie = get_cookie(PKTCOOKIE);
  44.         if(!cookie || !cookie->val) return(-1);
  45.         (long)n_release = ((long *)(cookie->val))[NETRELEASE];
  46.         if(!n_release) return(-1);
  47.     }
  48.     return(n_release(handle));
  49. }
  50.  
  51.  
  52. int net_send(int len, char *buf)
  53. {
  54. static int (*n_send)(int,char *) = NULL;
  55. COOKIE *cookie;
  56.     if(!n_send)
  57.     {
  58.         cookie = get_cookie(PKTCOOKIE);
  59.         if(!cookie || !cookie->val) return(-1);
  60.         (long)n_send = ((long *)(cookie->val))[NETSEND];
  61.         if(!n_send) return(-1);
  62.     }
  63.     return(n_send(len,buf));
  64. }
  65.  
  66. int    net_getadr(int len,char *buf)
  67. {
  68. static int (*n_getadr)(int,char *) = NULL;
  69. COOKIE *cookie;
  70.     if(!n_getadr)
  71.     {
  72.         cookie = get_cookie(PKTCOOKIE);
  73.         if(!cookie || !cookie->val) return(-1);
  74.         (long)n_getadr = ((long *)(cookie->val))[NETGETADR];
  75.         if(!n_getadr) return(-1);
  76.     }
  77.     return(n_getadr(len,buf));
  78. }
  79.  
  80.  
  81. int net_reset(void)
  82. {
  83. static int (*n_reset)(void) = NULL;
  84. COOKIE *cookie;
  85.     if(!n_reset)
  86.     {
  87.         cookie = get_cookie(PKTCOOKIE);
  88.         if(!cookie || !cookie->val) return(-1);
  89.         (long)n_reset = ((long *)(cookie->val))[NETRESET];
  90.         if(!n_reset) return(-1);
  91.     }
  92.     return(n_reset());
  93. }
  94.